<rd-header>
  <rd-header-title title-text="设置"></rd-header-title>
  <rd-header-content>设置</rd-header-content>
</rd-header>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-cogs" title-text="应用程序设置"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal">
          <!-- snapshot-interval -->
          <div class="form-group">
            <label for="snapshot_interval" class="col-sm-2 control-label text-left">快照间隔</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" ng-model="settings.SnapshotInterval" id="snapshot_interval" placeholder="例如：15m" />
            </div>
          </div>
          <!-- !snapshot-interval -->
          <!-- logo -->
          <div class="form-group">
            <div class="col-sm-12">
              <label for="toggle_logo" class="control-label text-left">
                用户自定义LOGO
              </label>
              <label class="switch" style="margin-left: 20px;"> <input type="checkbox" name="toggle_logo" ng-model="formValues.customLogo" /><i></i> </label>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <label for="toggle_enableTelemetry" class="control-label text-left">
                允许收集匿名统计数据
              </label>
              <label class="switch" style="margin-left: 20px;"> <input type="checkbox" name="toggle_enableTelemetry" ng-model="formValues.enableTelemetry" /><i></i> </label>
            </div>
            <div class="col-sm-12 text-muted small" style="margin-top: 10px;">
              你可以在我们的网站上找到更多的
              <a href="https://www.portainer.io/documentation/in-app-analytics-and-privacy-policy/" target="_blank">隐私政策</a>。
            </div>
          </div>
          <div ng-if="formValues.customLogo">
            <div class="form-group">
              <span class="col-sm-12 text-muted small">
                你可以在这里指定你的LOGO的URL。为了达到最佳显示效果，LOGO的尺寸应该是155px×55px。
              </span>
            </div>
            <div class="form-group">
              <label for="logo_url" class="col-sm-1 control-label text-left">
                URL
              </label>
              <div class="col-sm-11">
                <input type="text" class="form-control" ng-model="settings.LogoURL" id="logo_url" placeholder="https://mycompany.com/logo.png" />
              </div>
            </div>
          </div>
          <!-- !logo -->
          <!-- templates -->
          <div class="col-sm-12 form-section-title" hidden="true">
            应用程序模板
          </div>
          <div>
            <div class="form-group">
              <span class="col-sm-12 text-muted small">
                你可以在这里指定你自己的模板定义文件的URL。参见
                <a href="https://www.portainer.io/documentation/how-to-use-templates/" target="_blank">Portainer文档</a> 获取更多详细信息。
              </span>
            </div>
            <div class="form-group">
              <label for="templates_url" class="col-sm-1 control-label text-left">
                URL
              </label>
              <div class="col-sm-11">
                <input type="text" class="form-control" ng-model="settings.TemplatesURL" id="templates_url" placeholder="https://myserver.mydomain/templates.json" required />
              </div>
            </div>
          </div>
          <!-- !templates -->
          <!-- host-filesystem -->

          <!-- edge -->
          <div class="col-sm-12 form-section-title">
            Edge Compute
          </div>
          <div class="form-group">
            <label for="edge_checkin" class="col-sm-2 control-label text-left">
              Edge Agent 默认轮询频率
              <portainer-tooltip
                position="bottom"
                message="每个Edge代理默认使用的与Portainer实例签到的时间间隔。影响 Edge 端点管理和 Edge 计算功能。"
              ></portainer-tooltip>
            </label>
            <div class="col-sm-10">
              <select
                id="edge_checkin"
                class="form-control"
                ng-model="settings.EdgeAgentCheckinInterval"
                ng-options="+(opt.value) as opt.key for opt in state.availableEdgeAgentCheckinOptions"
              ></select>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <label for="toggle_enableEdgeComputeFeatures" class="control-label text-left">
                启用边缘计算功能
              </label>
              <label class="switch" style="margin-left: 20px;">
                <input type="checkbox" name="toggle_enableEdgeComputeFeatures" ng-model="formValues.enableEdgeComputeFeatures" /><i></i>
              </label>
            </div>
          </div>
          <!-- !edge -->
          <!-- actions -->
          <div class="form-group">
            <div class="col-sm-12">
              <button
                type="button"
                class="btn btn-primary btn-sm"
                ng-click="saveApplicationSettings()"
                ng-disabled="state.actionInProgress || !settings.TemplatesURL"
                button-spinner="state.actionInProgress"
              >
                <span ng-hide="state.actionInProgress">保存设置</span>
                <span ng-show="state.actionInProgress">设置保存中...</span>
              </button>
            </div>
          </div>
          <!-- !actions -->
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-tags" title-text="隐藏容器"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal" ng-submit="addFilteredContainerLabel()" name="addTagForm">
          <div class="form-group">
            <span class="col-sm-12 text-muted small">
              您可以从Portainer UI中隐藏带有特定标签的容器。您需要指定标签名称和值。
            </span>
          </div>
          <div class="form-group">
            <label for="header_name" class="col-sm-1 control-label text-left">名称</label>
            <div class="col-sm-11 col-md-4">
              <input type="text" required class="form-control" id="header_name" name="label_name" ng-model="formValues.labelName" placeholder="例如：com.example.foo" />
            </div>
            <label for="header_value" class="col-sm-1 margin-sm-top control-label text-left">值</label>
            <div class="col-sm-11 col-md-4 margin-sm-top">
              <input type="text" class="form-control" id="header_value" ng-model="formValues.labelValue" placeholder="例如：bar" />
            </div>
            <div class="col-sm-12 col-md-2 margin-sm-top">
              <button type="submit" class="btn btn-primary btn-sm" ng-disabled="!formValues.labelName"><i class="fa fa-plus space-right" aria-hidden="true"></i>Add filter</button>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12 table-responsive">
              <table class="table table-hover">
                <thead>
                  <tr>
                    <th>名称</th>
                    <th>值</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                  <tr ng-repeat="label in settings.BlackListedLabels">
                    <td>{{ label.name }}</td>
                    <td>{{ label.value }}</td>
                    <td
                      ><button type="button" class="btn btn-danger btn-xs" ng-click="removeFilteredContainerLabel($index)"
                        ><i class="fa fa-trash-alt space-right" aria-hidden="true"></i>移除</button
                      ></td
                    >
                  </tr>
                  <tr ng-if="settings.BlackListedLabels.length === 0">
                    <td colspan="3" class="text-center text-muted">没有可用的过滤器</td>
                  </tr>
                  <tr ng-if="!settings.BlackListedLabels">
                    <td colspan="3" class="text-center text-muted">加载中...</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
          <!-- !filtered-labels -->
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>

<div class="row">
  <div class="col-sm-12">
    <rd-widget>
      <rd-widget-header icon="fa-download" title-text="备份Portainer设置"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal" ng-submit="backupPortainer()" name="backupPortainerForm">
          <div class="col-sm-12 form-section-title">
            备份配置
          </div>
          <div class="form-group"></div>
          <div class="form-group">
            <div class="boxselector_wrapper">
              <div>
                <input type="radio" id="backup_file" checked="checked" />
                <label for="backup_file" style="padding-bottom: 20px;">
                  <div class="boxselector_header">
                    <i class="fa fa-download" aria-hidden="true" style="margin-right: 2px;"></i>
                    下载备份文件
                  </div>
                  <p></p>
                </label>
              </div>
              <div hidden="true">
                <input type="radio" id="backup_s3" disabled />
                <label for="backup_s3" class="boxselector_disabled" style="background-color: #ffffff;">
                  <div class="boxselector_header">
                    <i class="fa fa-upload" aria-hidden="true" style="margin-right: 2px;"></i>
                    Store in S3
                  </div>
                  <p>This feature is available in <a href="https://www.portainer.io/business-upsell?from=s3-backup-setting" target="_blank"> Portainer Business Edition</a></p>
                </label>
              </div>
            </div>
          </div>
          <div class="col-sm-12 form-section-title">
            安全设置
          </div>
          <!-- Password protect -->
          <div class="form-group">
            <label for="password_protect" class="col-sm-1 control-label text-left">密码保护</label>
            <div class="col-sm-1">
              <label class="switch"> <input type="checkbox" id="password_protect" name="password_protect" ng-model="formValues.passwordProtect" /><i></i> </label>
            </div>
          </div>
          <!-- !Password protect -->

          <!-- Password -->
          <div class="form-group" ng-if="formValues.passwordProtect">
            <label for="password" class="col-sm-1 control-label text-left">密码</label>
            <div class="col-sm-3">
              <input type="password" class="form-control" ng-model="formValues.password" id="password" name="password" required />
            </div>
          </div>
          <div class="form-group col-md-12" ng-show="backupPortainerForm.password.$invalid">
            <div class="small text-warning">
              <div ng-messages="backupPortainerForm.password.$error">
                <p ng-message="required"> <i class="fa fa-exclamation-triangle" aria-hidden="true"></i> 密码不能为空。</p>
              </div>
            </div>
          </div>
          <!-- !Password -->

          <!-- actions -->
          <div class="form-group">
            <div class="col-sm-12">
              <button
                type="button"
                class="btn btn-primary btn-sm"
                ng-click="downloadBackup()"
                ng-disabled="backupPortainerForm.$invalid || state.backupInProgress"
                button-spinner="state.backupInProgress"
              >
                <span ng-hide="state.backupInProgress">下载备份文件</span>
                <span ng-show="state.backupInProgress">备份文件下载中</span>
              </button>
            </div>
          </div>
          <!-- !actions -->
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>
